<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Control extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->load->view('template');
    }

    public function tambah_user() {
        $this->load->model('Sekolah_model');
        $query = $this->Sekolah_model->get_sekolah();
        
        $data['main_view'] = 'form_user';
        $data['query'] = $query;
        $data['form_action'] = 'control/tambah_user_process';
        
        $this->load->view('template', $data);
    }
    
    
    public function tambah_user_process() {
        $this->load->model('User_model');
        $this->User_model->insert();
        
        redirect('winsys/user');
    }
    
    

    public function tambah_sekolah() {
        $data['main_view'] = 'form_sekolah';
        $data['form_action'] = 'control/tambah_sekolah_process';
        
        $this->load->view('template', $data);
    }
    
    public function tambah_sekolah_process() {
        $this->load->model('Sekolah_model');
		$namaSekolah = $this->input->post('nama_sekolah');
		$jml = $this->input->post('jumlah_toilet');
		if($namaSekolah=='' || $jml==''){
			$data['error'] = "<span>Maaf, Anda belum mengisi form! </span>";
		}else{
			$this->Sekolah_model->insert();
			$data['error'] = "<span>Terima kasih telah mengisi form ini</span>";
		}
        
        redirect('winsys/sekolah');
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */